home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / utility / blrmu13.zip / DIVOP.ASM < prev    next >
Assembly Source File  |  1991-10-14  |  16KB  |  614 lines

  1. page ,132
  2. title divop ( display interrupt vectors on prtr ) - 10/14/91 - 03:35 pm
  3. ;*-------------------------------------------------
  4. ;
  5. ;   display interrupt vectors on printer
  6. ;  ( either all, empty, or used )
  7. ;  ( for all interrupts from 00 to FF )
  8. ;
  9. ;   vector table syntax : ( lo-hi format )
  10. ;   offset : segment
  11. ;   (word) : (word)
  12. ;
  13. ;   display syntax :      ( hi-lo format )
  14. ;   segment : offset
  15. ;   (word)    (word)
  16. ;*-------------------------------------------------
  17. ;*   syntax :
  18. ;*            divop a  ( all int vectors )
  19. ;*            divop e  ( empty only int vectors )
  20. ;*            divop u  ( used only int vectors )
  21. ;*-------------------------------------------------
  22. ;
  23. ;*---------------------------
  24. csroff   macro
  25. ;*---------------------------
  26. ;*   cursor off
  27. ;*---------------------------
  28. ;
  29.          push  ax
  30.          push  cx
  31.          mov   ah,1
  32.          mov   ch,32
  33.          int   10h
  34.          pop   cx
  35.          pop   ax
  36.          endm
  37. ;
  38. ;*---------------------------
  39. csron    macro
  40. ;*---------------------------
  41. ;*   cursor on
  42. ;*---------------------------
  43.          push  ax
  44.          push  cx
  45.          mov   ah,1
  46.          mov   ch,stcsl                ; restore the crsr start line
  47.          mov   cl,stcel                ; restore the crsr end line
  48.          int   10h
  49.          pop   cx
  50.          pop   ax
  51.          endm
  52. ;
  53. ;*---------------------------
  54. csrsv    macro
  55. ;*---------------------------
  56. ;*   cursor save
  57. ;*---------------------------
  58.          push  ax
  59.          push  bx
  60.          push  cx
  61.          mov   ah,3
  62.          mov   bh,0
  63.          int   10h
  64.          mov   stcsl,ch                ; save the crsr start line
  65.          mov   stcel,cl                ; save the crsr end line
  66.          pop   cx
  67.          pop   bx
  68.          pop   ax
  69.          endm
  70. ;
  71. ;*-------------------------------------
  72. ;*   direct console input
  73. ;*-------------------------------------
  74. dci      macro cic
  75.          mov   ah,7
  76.          int   21h
  77.          mov   cic,al
  78.          endm
  79. ;
  80. ;*----------------------------------
  81. ;*   display character on printer
  82. ;*----------------------------------
  83. dcop     macro poc
  84.          mov   dl,poc
  85.          mov   ah,5
  86.          int   33
  87.          endm
  88. ;
  89. ;*------------------------------------
  90. lm       macro msg
  91. ;*------------------------------------
  92. ;*  list message
  93. ;*------------------------------------
  94.          lea   ax,msg
  95.          call  lmts
  96.          endm
  97. ;
  98. ;*--------------------------------------
  99. mswl     macro dest,sors,len
  100. ;*--------------------------------------
  101. ;* move short with length
  102. ;---------------------------------------
  103. ;* dest = destination of move
  104. ;* sors = source of move
  105. ;* len  = max length of move
  106. ;--------------------------------------
  107. ;* length may be from 1 to 255
  108. ;* length must be db if variable
  109. ;*--------------------------------------
  110.          push  cx
  111.          push  di
  112.          push  si
  113.          mov   ch,0
  114.          mov   cl,len
  115.          lea   di,dest
  116.          lea   si,sors
  117.          cld
  118.          rep   movsb
  119.          pop   si
  120.          pop   di
  121.          pop   cx
  122.          endm
  123. ;
  124. ;*------------------------------------
  125. pc       macro fld,len,char
  126. ;*------------------------------------
  127. ;* propagate character
  128. ;*------------------------------------
  129. ;* the area named 'fld',
  130. ;* for a length of 'len'
  131. ;* will be filled with 'char'
  132. ;*------------------------------------
  133.          push  ax
  134.          push  cx
  135.          push  di
  136.          lea   di,fld
  137.          mov   cx,len
  138.          mov   al,char
  139.          cld
  140.          rep   stosb
  141.          pop   di
  142.          pop   cx
  143.          pop   ax
  144.          endm
  145. ;
  146. ;*------------------------------------
  147. pm       macro msg
  148. ;*------------------------------------
  149. ;* print message
  150. ;* ( by calling pmtp )
  151. ;*------------------------------------
  152.          lea   ax,msg
  153.          call  pmtp
  154.          endm
  155. ;
  156. ;*--------------------------------------
  157. rk       macro kpa
  158. ;*--------------------------------------
  159. ;* read keyboard
  160. ;*--------------------------------------
  161. ;* kpa = keyboard parameter area
  162. ;* function 10 = read buffered keyboard
  163. ;*--------------------------------------
  164.          lea   dx,kpa
  165.          mov   ah,10
  166.          dc
  167.          endm
  168. ;*--------------------------------------
  169. ;
  170. ;   equates
  171. ;
  172. z        equ   0
  173. four     equ   4
  174. lf       equ   10
  175. tof      equ   12
  176. cr       equ   13
  177. mlc      equ   30
  178. ;
  179.          .model small
  180.          .code
  181. ;
  182. ;   parm area
  183. ;
  184.          org   128
  185. ;
  186. pl       db    0                       ; parm len ( includes space )
  187.          db    0                       ; space
  188. aeu      db    0                       ; 'a', 'e', 'u'
  189. ;
  190.          org   256
  191. ;
  192. go:      jmp   divs
  193. ;
  194. ;   data section
  195. ;
  196. stcsl    db    z                       ; save the crsr start line
  197. stcel    db    z                       ; save the crsr end line
  198. ;
  199. voa1     db    z                       ; vector offset address 1
  200. voa2     db    z                       ; vector offset address 2
  201. vsa1     db    z                       ; vector segment address 1
  202. vsa2     db    z                       ; vector segment address 2
  203. ;
  204. ;  vector address msg
  205. ;
  206. vam      db    cr,lf
  207.          db    ' * interrupt # = '
  208. vin      db    'xx'
  209.          db    ' - vector addresses : '
  210.          db    ' segment = '
  211. vsv      db    'xxxx'
  212.          db    ' , '
  213.          db    ' offset = '
  214. vov      db    'xxxx'
  215.          db    cr,lf,z
  216. ;
  217. hm       db    '<===   xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx   ===>'
  218.          db    0,0,0
  219. hma      db    '<===   printed list of all   interrupt vectors   ===>'
  220. hme      db    '<===   printed list of empty interrupt vectors   ===>'
  221. hmf      db    '<===   printed list of used  interrupt vectors   ===>'
  222. ;
  223. lhm      db    13,10,10
  224.          db    ' * interrupt vectors being printed * '
  225.          db    13,10,10,0
  226. ;
  227. ff       db    tof,z                   ; top of form
  228. cll      db    cr,lf,lf,z              ; cr, lf, lf
  229. ;
  230. rr       db    z                       ; reg result
  231. lc       db    z                       ; line count
  232. rv       db    z                       ; req value
  233. poc      db    z                       ; prt out char
  234. mrv      dw    z                       ; mult req value
  235. mbtf     dw    z                       ; work field
  236. tolf     db    z                       ; type of list flag
  237. ;
  238. ;  code section
  239. ;
  240. divs:
  241. ;
  242. ;   check command line
  243. ;
  244. ccl:
  245.          mov   tolf,'a'                ; set flag for all
  246.          mswl  hm,hma,53               ; set msg for all
  247. ;
  248.          cmp   pl,0                    ; parm len = 0 ?
  249.          je    gaiv                    ; if so, default
  250. ;
  251. ;  check passed parameters
  252. ;
  253.          cmp   aeu,'a'                 ; all ?
  254.          je    gaiv                    ; if so, do it
  255.          cmp   aeu,'e'                 ; empty ?
  256.          jne   cfupp                   ; if not, chk for used
  257.          mov   tolf,'e'                ; if so, set for empty
  258.          mswl  hm,hme,53               ; set msg for empty
  259.          jmp   gaiv                    ; do it
  260. cfupp:
  261.          cmp   aeu,'u'                 ; used ?
  262.          jne   gaiv                    ; if not, do it
  263.          mov   tolf,'u'                ; if so, set for used
  264.          mswl  hm,hmf,53               ; set msg for used
  265.          jmp   gaiv                    ; do it
  266. ;
  267. ;  get all int vectors
  268. ;
  269. gaiv:
  270. ;
  271.          csrsv                         ; cursor save
  272.          csroff                        ; cursor off
  273.          call  green                   ; set scrn to green
  274.          call  dhr                     ; display hdg rtn
  275.          lm    cll                     ; cr, lf, lf
  276.          lm    lhm                     ; list hdg msg
  277. ;
  278. ;     get and display
  279. ;
  280. ;   ( the interrupt vector address contents )
  281. ;   ( for all interrupt vectors )
  282. ;
  283. gad:
  284.          push  es                      ; save es
  285. ;
  286.          mov   ax,0                    ; set es
  287.          mov   es,ax                   ; to 0
  288.          mov   bx,mrv                  ; set bx to request
  289. ;
  290.          cmp   tolf,'a'                ; all ?
  291.          je    gc
  292. ;
  293.          mov   cx,es:[bx]              ; get addresses
  294.          mov   dx,es:[bx+2]            ; for empty/full check
  295. ;
  296.          cmp   cx,0                    ; empty ?
  297.          je    cdx                     ; if so, carry on
  298.          jmp   cff                     ; else, chk full flag
  299. cdx:
  300.          cmp   dx,0                    ; empty ?
  301.          je    cef                     ; if so, chk empty flag
  302.          jmp   co                      ; else, give up
  303. ;
  304. cef:
  305.          cmp   tolf,'e'                ; empty ?
  306.          je    gc                      ; if so, do it
  307.          jmp   co                      ; give up
  308. cff:
  309.          cmp   tolf,'u'                ; used ?
  310.          je    gc                      ; if so, do it
  311.          jmp   co                      ; give up
  312. ;
  313. gc:
  314.          mov   al,es:[bx]              ; get contents
  315.          mov   voa2,al                 ; of vector
  316.          mov   al,es:[bx+1]            ; offset
  317.          mov   voa1,al                 ; address
  318. ;
  319.          mov   al,es:[bx+2]            ; get contents
  320.          mov   vsa2,al                 ; of vector
  321.          mov   al,es:[bx+3]            ; segment
  322.          mov   vsa1,al                 ; address
  323. ;
  324.          pop   es                      ; restore es
  325. ;
  326. ;    display vector address msg
  327. ;
  328.          mov   al,rv
  329.          call  chta
  330.          mov   vin,dh
  331.          mov   vin+1,dl
  332. ;
  333.          mov   al,voa1
  334.          call  chta
  335.          mov   vov,dh
  336.          mov   vov+1,dl
  337. ;
  338.          mov   al,voa2
  339.          call  chta
  340.          mov   vov+2,dh
  341.          mov   vov+3,dl
  342. ;
  343.          mov   al,vsa1
  344.          call  chta
  345.          mov   vsv,dh
  346.          mov   vsv+1,dl
  347.  ;
  348.          mov   al,vsa2
  349.          call  chta
  350.          mov   vsv+2,dh
  351.          mov   vsv+3,dl
  352. ;
  353.          pm    vam
  354. ;
  355.          add   lc,1
  356.          cmp   lc,mlc
  357.          jb    co
  358.          call  dhr
  359. ;
  360. co:
  361.          add   rv,1
  362.          add   mrv,four
  363.          cmp   mrv,1020                ; interrupt FF ?
  364.          ja    stop
  365.          jmp   gad
  366. ;
  367. stop:
  368. ;
  369.          lm    cll
  370.          csron
  371.          pm    cll
  372.          pm    ff
  373. ;
  374.          mov   al,0         ; set cond code to 0
  375.          mov   ah,76        ; and exit
  376.          int   33
  377. ;
  378. ;  display hdg rtn
  379. ;
  380. dhr      proc  near
  381.          mov   lc,0
  382.          pm    ff
  383.          pm    hm
  384.          pm    cll
  385.          ret
  386. dhr      endp
  387. ;
  388. ;*------------------------------
  389. ;*   catb.prc
  390. ;*------------------------------
  391. ;*   convert ascii to binary
  392. ;*------------------------------
  393. ;* converts an ascii decimal
  394. ;* input number
  395. ;* pointed to by si,
  396. ;* to a dw binary output field
  397. ;* pointed to by di,
  398. ;* with the input field width
  399. ;* in bx,
  400. ;* and using a dw multiply
  401. ;* temporary field named mbtf
  402. ;*------------------------------
  403. catb     proc  near
  404.          push  ax
  405.          push  cx
  406.          mov   cx,10
  407.          mov   mbtf,1
  408.          sub   si,1
  409. ;
  410. catbl:
  411.          mov   al,[si+bx]
  412.          and   ax,000fh
  413.          mul   mbtf
  414.          add   [di],ax
  415.          mov   ax,mbtf
  416.          mul   cx
  417.          mov   mbtf,ax
  418.          dec   bx
  419.          jnz   catbl
  420.          pop   cx
  421.          pop   ax
  422.          ret
  423. catb     endp
  424. ;
  425. ;*-------------------------------
  426. ;   cath.prc
  427. ;*-------------------------------
  428. ;* convert ascii to hex
  429. ;* byte is in al both ways
  430. ;*-------------------------------
  431. cath     proc  near
  432.          sub   al,48
  433.          jb    athe
  434.          cmp   al,10
  435.          jb    athx
  436.          sub   al,39
  437.          cmp   al,16
  438.          jnb   athe
  439.          cmp   al,10
  440.          jnb   athx
  441. athe:    mov   al,255
  442. athx:    ret
  443. cath     endp
  444. ;
  445. ;*-----------------------------------------------
  446. ;   cbwtas.prc
  447. ;*-----------------------------------------------
  448. ;*   convert binary word to ascii string
  449. ;*-----------------------------------------------
  450. ;*  before call set :
  451. ;*
  452. ;* ax = binary number
  453. ;* bx = length of output field
  454. ;* si = pointer to output field
  455. ;*------------------------------------------------
  456. cbwtas   proc  near
  457.          push  cx
  458.          push  dx
  459.          mov   cx,10
  460.          sub   bx,1
  461.          add   si,bx
  462. ;
  463. cbtavsl:
  464.          cmp   ax,0010
  465.          jb    cbtavsx
  466.          sub   dx,dx
  467.          div   cx
  468.          or    dl,48
  469.          mov   [si],dl
  470.          dec   si
  471.          jmp   cbtavsl
  472. ;
  473. cbtavsx:
  474.          or    al,48
  475.          mov   [si],al
  476.          pop   dx
  477.          pop   cx
  478.          ret
  479. cbwtas   endp
  480. ;
  481. ;*--------------------------------------
  482. ;*   chta.prc
  483. ;*--------------------------------------
  484. ;* convert hex to ascii ( 1 byte )
  485. ;*--------------------------------------
  486. ;* byte to be converted is passed in al
  487. ;* the hi nibble is passed back in dh
  488. ;* the lo nibble is passed back in dl
  489. ;*--------------------------------------
  490. ;
  491. chta     proc  near
  492. ;   convert hi nibble
  493.          mov   dh,al  ; move byte for hi conversion
  494.          shr   dh,1   ; shift
  495.          shr   dh,1   ; out
  496.          shr   dh,1   ; lo
  497.          shr   dh,1   ; nibble
  498.          add   dh,48  ; add ascii zero
  499.          cmp   dh,58  ; > than 9 ?
  500.          jl    chtadl ; if not, carry on
  501.          add   dh,7   ; else, convert to a-f
  502. chtadl:
  503. ;   convert lo nibble
  504.          mov   dl,al  ; move byte for lo conversion
  505.          and   dl,15  ; get rid of hi nibble
  506.          add   dl,48  ; add ascii zero
  507.          cmp   dl,58  ; > than 9 ?
  508.          jl    chtax  ; if not, carry on
  509.          add   dl,7   ; else, convert to a-f
  510. chtax:
  511.          ret
  512. chta     endp
  513. ;
  514. ;*-------------------------
  515. ;*   green prc
  516. ;*-------------------------
  517. ;*   change screen to
  518. ;*   white on green
  519. ;*-------------------------
  520. ;
  521. green    proc  near
  522. ;
  523.          mov   ah,11                   ; set color palette fct
  524.          mov   bh,0                    ; text mode
  525.          mov   bl,15                   ; border = white
  526.          int   16
  527. ;
  528.          mov   ah,2                    ; set cursor position fct
  529.          mov   bh,0                    ; page number 0
  530.          mov   dh,0                    ; row 0
  531.          mov   dl,0                    ; col 0
  532.          int   16
  533. ;
  534.          mov   ah,9                    ; write char and attr fct
  535.          mov   al,32                   ; char = space
  536.          mov   bh,0                    ; page number 0
  537.          mov   bl,47                   ; attr = green back, white crsr
  538.          mov   cx,2000                 ; 25 * 80
  539.          int   16
  540. ;
  541.          ret
  542. green    endp
  543. ;
  544. ;*------------------------------
  545. ;*     lmts.prc
  546. ;*------------------------------
  547. ;*   list msg to screen
  548. ;*------------------------------
  549. ;*   called by macro lm
  550. ;*   using ax as ptr to msg
  551. ;*------------------------------
  552. ;*  msg terminated by final zero
  553. ;*  or max 512 bytes
  554. ;*------------------------------
  555. lmts     proc  near
  556.          push  ax
  557.          push  bx
  558.          push  cx
  559.          push  si
  560.          mov   bx,ax
  561.          mov   cx,512
  562.          mov   si,0
  563. lmtsl:
  564.          mov   al,[bx][si]
  565.          cmp   al,0
  566.          je    lmtsx
  567.          int   41
  568.          inc   si
  569.          loop  lmtsl
  570. lmtsx:
  571.          pop   si
  572.          pop   cx
  573.          pop   bx
  574.          pop   ax
  575.          ret
  576. lmts     endp
  577. ;
  578. ;*------------------------------
  579. ;*    pmtp.prc
  580. ;*------------------------------
  581. ;*   print msg (to printer)
  582. ;*------------------------------
  583. ;*   called by macro pm
  584. ;*   using ax as ptr to msg
  585. ;*------------------------------
  586. ;*  msg terminated by final zero
  587. ;*  or max 512 bytes
  588. ;*------------------------------
  589. pmtp     proc  near
  590.          push  ax
  591.          push  bx
  592.          push  cx
  593.          push  si
  594.          mov   bx,ax
  595.          mov   cx,512
  596.          mov   si,0
  597. pmtpl:
  598.          mov   al,[bx][si]
  599.          cmp   al,0
  600.          je    pmtpx
  601.          mov   poc,al
  602.          dcop  poc
  603.          inc   si
  604.          loop  pmtpl
  605. pmtpx:
  606.          pop   si
  607.          pop   cx
  608.          pop   bx
  609.          pop   ax
  610.          ret
  611. pmtp     endp
  612. ;
  613.          end   go
  614.